home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / pc / files / t_sys5 / unixkit.tgz / unixkit.tar / unixkit / lwp / proc.h < prev   
Encoding:
C/C++ Source or Header  |  1991-11-22  |  2.6 KB  |  78 lines

  1. #ifndef    PHASH
  2.  
  3. #ifndef MINPRIO
  4. #include <lwp/lwp.h>
  5. #endif
  6. #include <lwp/stackdep.h>
  7. #include "timer.h"
  8.  
  9. #define    OUTBUFSIZE    512    /* Size to be malloc'ed for outbuf */
  10.  
  11. /* Kernel process control block */
  12. #define    PHASH    16        /* Number of wait table hash chains */
  13. struct proc {
  14.     struct proc *prev;    /* Process table pointers */
  15.     struct proc *next;    
  16.  
  17.     char i_state;        /* Process interrupt state */
  18.  
  19.     unsigned short state;
  20. #define    READY    0
  21. #define    WAITING    1
  22. #define    SUSPEND    2
  23.     void *event;        /* Wait event */
  24.  
  25. /* As the man page for LWPs states, stacks are problematic for light-weight
  26.    processes... this is a major understatement!
  27.    Our approach:
  28.    Stacks must be aligned on a sktalign_t boundary... but we really need
  29.    to deal with stack sizes consistently.  So, we will define the stack
  30.    as an array of type int... and we will deal with it as such.
  31.    stkalign_t is defined as an int on the Sun386i and the Sun-3 machines,
  32.    and as a double on the SPARC (Sun-4) machines.  We will align to a
  33.    doubleword boundary on all, and avoid the whole stkalign_t bit.
  34.  
  35.    For easier stack manipulations, we will record the stack bottom
  36.    as well.  This is the chunk we malloc'd for the stack.  The first
  37.    int is used to mark the stack bottom, and the remainder may
  38.    be filled with the stack pattern.  This can then be quickly tested
  39.    to find overrun stacks and such. */
  40.  
  41.     int *stack;        /* Process stack */
  42.     int stksize;        /* Size of same (in ints) */
  43.     int *stackbottom;    /* Bottom of the stack */
  44.  
  45.     char *name;        /* Arbitrary user-assigned name */
  46.     int retval;        /* Return value from next pwait() */
  47.     struct timer alarm;    /* Alarm clock timer */
  48.     struct mbuf *outbuf;    /* Terminal output buffer */
  49.     int input;        /* standard input socket */
  50.     int output;        /* standard output socket */
  51.     int iarg;        /* Copy of iarg */
  52.     void *parg1;        /* Copy of parg1 */
  53.     void *parg2;        /* Copy of parg2 */
  54.     int freeargs;        /* Free args on termination if set */
  55.     thread_t tid;        /* LWP thread ID */
  56. };
  57. #define NULLPROC (struct proc *)0
  58. extern struct proc *Waittab[];    /* Head of wait list */
  59. extern struct proc *Rdytab;    /* Head of ready list */
  60. extern struct proc *Curproc;    /* Currently running process */
  61.  
  62. /* In  kernel.c: */
  63. void alert __ARGS((struct proc *pp,int val));
  64. void chname __ARGS((struct proc *pp,char *newname));
  65. void killproc __ARGS((struct proc *pp));
  66. void killself __ARGS((void));
  67. struct proc *mainproc __ARGS((char *name));
  68. struct proc *newproc __ARGS((char *name,unsigned int stksize,
  69.     void (*pc) __ARGS((int,void *,void *)),
  70.     int iarg,void *parg1,void *parg2,int freeargs));
  71. int psignal __ARGS((void *event,int n));
  72. int pwait __ARGS((void *event));
  73.  
  74. #define STACKPAT 0x5a6b7c8d
  75. #define STACKBOT 0x12345678
  76.  
  77. #endif    /* PHASH */
  78.